    //
//  FeedDetailWithWebviewController.m
//  NewsReader
//
//  Created by blacksun on 11-1-6.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "FeedDetailWithWebviewController.h"


@implementation FeedDetailWithWebviewController
@synthesize feed;
@synthesize webView;
@synthesize activityView;
@synthesize linkLabel;

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	[super viewDidLoad];
	self.webView.delegate = self;
	self.linkLabel.text = self.feed.link;
	
	self.linkLabel.layer.cornerRadius = 3;
	self.linkLabel.layer.masksToBounds = YES;
	UIScrollView *scroll =  [self.webView.subviews objectAtIndex:0];
	scroll.bounces = NO;
	NSURL *url = [[NSURL alloc] initWithString:self.feed.link];
	NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
	[self.webView loadRequest:request];
	
	[request release];
	[url release];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)webViewDidStartLoad:(UIWebView *)aWebView{
}
- (void)webViewDidFinishLoad:(UIWebView *)aWebView{
	[self.activityView stopAnimating];
}

-(IBAction) popController{
	[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	if ([self.webView isLoading]) {
		[self.webView stopLoading];
	}
	[self.webView release];
	[self.feed release];
	[self.activityView release];
	[self.linkLabel release];
    [super dealloc];
}


@end
